cmake_minimum_required(VERSION 3.16)

# 设置项目名称和版本
project(duckdb_test VERSION 1.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置自动生成moc文件
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 查找Qt包
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Sql Test)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Sql Test)

# 添加可执行文件
add_executable(duckdb_test
    main.cpp
    duckdbsqldrivertest.cpp
    duckdbsqldrivertest.h
)

# 链接Qt库
target_link_libraries(duckdb_test PRIVATE
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Sql
    Qt${QT_VERSION_MAJOR}::Test
)

# 启用测试
enable_testing()
add_test(NAME duckdb_test COMMAND duckdb_test)

# 如果需要链接到特定的DuckDB库，可以在这里添加
# 例如：
# target_link_libraries(duckdb_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../libduckdb/win/duckdb.lib)

# 安装规则
if(UNIX AND NOT APPLE)
    install(TARGETS duckdb_test DESTINATION bin)
endif()